#!/bin/bash
# postrm script for cpu-scheduler

set -e

case "$1" in
    remove|purge)
        # 停止并禁用服务
        systemctl stop cpu-scheduler.service >/dev/null 2>&1 || true
        systemctl disable cpu-scheduler.service >/dev/null 2>&1 || true
        
        # 删除服务文件
        rm -f /etc/systemd/system/cpu-scheduler.service
        rm -f /etc/cpu-scheduler.conf
        rm -f /var/log/cpu-scheduler.log

        # 更新桌面数据库
        if [ -x /usr/bin/update-desktop-database ]; then
            update-desktop-database /usr/share/applications/ >/dev/null 2>&1 || true
        fi
        
        # 更新图标缓存
        if [ -x /usr/bin/gtk-update-icon-cache ]; then
            gtk-update-icon-cache -f /usr/share/icons/hicolor >/dev/null 2>&1 || true
        fi
    ;;
esac

exit 0